import 'package:flutter/material.dart';
import 'package:flutter_cost/pojo/mykeyboard.dart';
import 'package:get/get.dart';

import 'state.dart';

class BillLogic extends GetxController with GetSingleTickerProviderStateMixin {
  final BillState state = BillState();

  TabController? tabController;

  @override
  void onInit() {
    super.onInit();
    tabController = TabController(vsync: this, length: 3)..addListener(() {
      if (null != tabController) {
        state.currentItem.value = tabController!.index;
        print("item=${state.currentItem.value}");
      }
    });

    state.keys.add(MyKeyboard(1, "1"));
    state.keys.add(MyKeyboard(2, "2"));
    state.keys.add(MyKeyboard(3, "3"));
    state.keys.add(MyKeyboard(10, "删除"));
    state.keys.add(MyKeyboard(4, "4"));
    state.keys.add(MyKeyboard(5, "5"));
    state.keys.add(MyKeyboard(6, "6"));
    state.keys.add(MyKeyboard(11, "-"));
    state.keys.add(MyKeyboard(7, "7"));
    state.keys.add(MyKeyboard(8, "8"));
    state.keys.add(MyKeyboard(9, "9"));
    state.keys.add(MyKeyboard(12, "+"));
    state.keys.add(MyKeyboard(13, "再记"));
    state.keys.add(MyKeyboard(0, "0"));
    state.keys.add(MyKeyboard(14, "."));
    state.keys.add(MyKeyboard(15, "保存"));
  }

  @override
  void onClose() {
    super.onClose();
    tabController?.dispose();
  }
}
